/*
    SUSAN® - Sole of Unix Save ANything

   Copyright (C) 2014-2014 Skyatlas Co. CN
   Copyright (C) 2014-2020 Hechzh Property

   
*/
/*
 * Marco van Wieringen, June 2014
 */
/**
 * @file
 * Dynamic loading of SD backend plugins.
 */

#ifndef BAREOS_STORED_SD_BACKENDS_H_
#define BAREOS_STORED_SD_BACKENDS_H_ 1

namespace storagedaemon {

class BackendInterface {
 public:
  virtual Device* GetDevice(JobControlRecord* jcr, DeviceType device_type) = 0;
  virtual void FlushDevice(void) = 0;
};


extern "C" {
typedef BackendInterface* (*t_backend_base)(void);
BackendInterface* GetBackend(void);
}

#if defined(HAVE_WIN32)
#define DYN_LIB_EXTENSION ".dll"
#elif defined(HAVE_DARWIN_OS)
/* cmake MODULE creates a .so files; cmake SHARED creates .dylib */
// #define DYN_LIB_EXTENSION ".dylib"
#define DYN_LIB_EXTENSION ".so"
#else
#define DYN_LIB_EXTENSION ".so"
#endif


#if defined(HAVE_DYNAMIC_SD_BACKENDS)
void SetBackendDeviceDirectories(std::vector<std::string>&& new_backend_dirs);
Device* InitBackendDevice(JobControlRecord* jcr, DeviceType device_type);
void FlushAndCloseBackendDevices();
#endif

} /* namespace storagedaemon */

#endif /* __SD_DYNAMIC_H_ */
